<?php

class Asd_Validator_Passwordmatch extends Zend_Validate_Abstract{
    const NOT_MATCH = 'notMatch';
        
    protected $_messageTemplates = array(
        self::NOT_MATCH => 'Сыр сөз дал келбеди.'
    );
    
    public function isValid($value) {
        
        $db = Zend_Db_Table::getDefaultAdapter();
        $result = $db->fetchRow($db->select()
                ->from('users', array('user_password'))
                ->where('user_id = ?', Zend_Auth::getInstance()->getIdentity()->user_id));
        
        if ($result['user_password'] == sha1($value)) {
            return true;
        }
                
        $this->_error(self::NOT_MATCH);  
        return false;
    }
}
